package com.myjob.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import com.myjob.entity.Comment;

import java.util.List;

@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
	@Select("SELECT c.blog_id, c.comment_id, c.content, c.create_date, c.deleted, c.parent_id, c.user_id, u.user_name \n" +
			"FROM comment c \n" +
			"LEFT JOIN user u ON c.user_id = u.user_id\n" +
			"WHERE c.blog_id=#{blogId}")
	public List<Comment> selectComments(@Param("blogId") String blogId);

	@Update("UPDATE `comment` SET parent_id=#{parentId} WHERE parent_id=#{commentId}")
	public void updateCommentsByParent(@Param("commentId") String commentId,
									   @Param("parentId") String parentId);
}